package com.LFLWZ.serivceImpl;

import com.LFLWZ.beans.POJO.ClassroomCourse;
import com.LFLWZ.beans.POJO.Column;
import com.LFLWZ.beans.Vo.ColumnVo;
import com.LFLWZ.mapper.ColumnMapper;
import com.LFLWZ.service.ColumnService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class ColumnServiceImpl implements ColumnService {
    @Autowired private ColumnMapper columnMapper;

    /***
     *调用Mapper,新增专栏
     * @param columnVo 专栏实体类
     * @return 返回行数
     */
    @Override
    public int ins(ColumnVo columnVo) {
        return columnMapper.ins(columnVo);
    }

    /***
     * 查询专栏数据
     * @param uid 用户ID
     * @return 所得数据
     */
    @Override
    public List<Column> selall(Integer uid) {
        return columnMapper.selall(uid);
    }

    /***
     * 通过主键查询专栏详情
     * @param id 主键
     * @return 详情数据
     */
    @Override
    public List<ColumnVo> selById(Integer id) {
        List<ColumnVo> columnVos= columnMapper.selById(id);
        for (ColumnVo columnVo:columnVos){
            columnVo.setClassroomCourses(columnMapper.selCourseById(columnVo.getId()));
        }
        return columnVos;
    }

    /***
     * 通过实体类修改数据库数据
     * @param column 实体类
     * @return 影响行数
     */
    @Override
    public int colup(Column column) {
        return columnMapper.colup(column);
    }

    @Override
    public List<Column> sel(Column column) {
        return columnMapper.sel(column);
    }

    @Override
    public List<Column> selsta(Column column) {
        return columnMapper.selsta(column);
    }

    @Override
    public int del(Integer id) {
        return columnMapper.del(id);
    }

}
